#include "stdafx.h"
#include "Matrix/Matrix.h"
using namespace std;

CMatrix m;

void addWord(const CrossWordItem& item)
{
	if (!m.addWord(item))
		wcout << L"Failed to add word " << item.word << endl;
}

void addWord(const wchar_t* a, const wchar_t* b, int c)
{
	CrossWordItem item = { a, b, c };
	addWord(item);
}

int _tmain(int argc, _TCHAR* argv[])
{
	m.init(7);
	wcout.imbue(locale("rus_rus.866"));
	vector<CrossWordItem> items;
	if (!readWords("words3.txt", items))
	{
		cout << "Error reading words" << endl;
		return -1;
	}

 	if (!m.setAnchor(items[98]))
 		wcout << L"Failed to add word " << items[105].word << endl;
	int added = 1;

	for (size_t i = 1; i < items.size() && added < 7; i++)
	{
		if (m.addWord(items[items.size() - i]))
			added++;
	}

	m.dump();
/*
	{
		MatrixItem item = { "fish", "ball", 2 };
		m.addWord(item);
	}
	{
		MatrixItem item = { "car", "ball", 2 };
		m.addWord(item);
	}
	{
		MatrixItem item = { "tram", "ball", 2 };
		m.addWord(item);
	}
*/
	return 0;
}

